﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Playlist.Models;
using Playlist.Models.BindingsModel;

namespace Playlist.Controllers
{
    [RoutePrefix("api/YouTube")]
    public class YouTubeController : ApiController
    {
        [Route("PostSolicitud")]
        public IHttpActionResult PostSolicitud(RequestBindingModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return BadRequest(ModelState);
                }

                //GUARDAR PETICIÓN DEL USUARIO EN LA COLA
                
                return Ok();
            }
            catch (Exception)
            {
                return InternalServerError();
            }

        }

        [Route("ListadoBares")]
        [HttpGet]
        public List<BarBindingModel> ListadoBares()
        {
            List<BarBindingModel> lstBares = new List<BarBindingModel>();
            try
            {
                //Consultar el listado de Bares (Objeto Combo en la app móvil).

                BarBindingModel objBar = new BarBindingModel();
                objBar.BarId = 1;
                objBar.BarDescripcion = "Playlist Bar!";

                return lstBares;
            }
            catch (Exception)
            {
                return lstBares;
            }
        }

        [Route("Prueba")]
        [HttpGet]
        public string Prueba()
        {
            try
            {
                //GUARDAR PETICIÓN DEL USUARIO EN LA COLA

                return "Funciona al pelo";
            }
            catch (Exception)
            {
                return "KO"; ;
            }

        }

        #region Métodos propios de la clase API (GET, SET, PUT, POST)

        // GET: api/YouTube
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET: api/YouTube/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/YouTube
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/YouTube/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/YouTube/5
        public void Delete(int id)
        {
        }

        #endregion
    }
}